package com.pinganfu.tesla.iwallet;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.pinganfu.tesla.iwallet.util.TeslaUtil;
import compinganfu.tesla.iwallet.widget.EditTextWithDel;

public class AddCardConfirmActivity extends Activity implements OnClickListener {

	private Intent intentAddCard = null;
	private EditTextWithDel txtVerifyCode;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_card_confirm);

		intentAddCard = getIntent();

		TextView tvAddCardTip = (TextView) findViewById(R.id.tv_add_card_tip);
		tvAddCardTip.setText("请输入手机(" + intentAddCard.getStringExtra("mobileNo") + ")收到的短信验证码");

		Button btnNext = (Button) findViewById(R.id.btn_next);
		btnNext.setOnClickListener(this);

		txtVerifyCode = (EditTextWithDel) findViewById(R.id.txt_verify_code);
		txtVerifyCode.setActionButton(btnNext);

		((Button) findViewById(R.id.btn_resend)).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.btn_next :
				showAlertDialog();
				break;
			case R.id.btn_resend :
				txtVerifyCode.setText("888888");
				break;
		}
	}

	private void showAlertDialog() {
		AlertDialog.Builder alert = new AlertDialog.Builder(this);
		alert.setTitle(R.string.lbl_tips);
		alert.setMessage(R.string.msg_bind_card_succ);
		alert.setCancelable(false);
		alert.setPositiveButton(R.string.lbl_confirm, new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				TeslaUtil.gotoActivity(AddCardConfirmActivity.this, MainActivity.class);
			}
		});
		alert.show();
	}
}
